package gui.frame;

import java.awt.Button;
import java.awt.Dialog;
import java.awt.Event;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;

public class FrameButtonTest extends Frame {

	TextField rows = new TextField("3");
	TextField cols = new TextField("3");

	FrameButtonTest() {
		this.setTitle("Frame Button Test");
		Panel p = new Panel();
		p.setLayout(new GridLayout(2, 2));
		p.add(new Label("Rows", Label.CENTER));
		p.add(rows);
		p.add(new Label("Cols", Label.CENTER));
		p.add(cols);
		
		this.add("North",p);
		this.add("South",new Button("Go"));
	}
	
	public boolean handleEvent(Event evt){
		if(evt.id==Event.WINDOW_DESTROY)
			System.exit(0);
		else
			return super.handleEvent(evt);
		return true;
	}
	
	public boolean action(Event evt,Object obj){
		if(obj.equals("Go")){
			Dialog d=new ToeDialog(this,Integer.parseInt(rows.getText()),Integer.parseInt(cols.getText()));
			d.show();
		}else
			return super.action(evt, obj);
		return true;
		
	}
	
	public static void main(String[]args){
		Frame frame=new FrameButtonTest();
		frame.resize(200, 100);
		frame.show();
	}
}
